/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.util.List;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import pojo.Nhanxet;
import until.HibernateUtil;

/**
 *
 * @author Admin
 */
public class nhanXetDAO {

    public static List<Nhanxet> HienThiNhanXet() {
        List<Nhanxet> ds = null;
        Session sc = HibernateUtil.getSessionFactory().openSession();
        try {
            String hql = "from Nhanxet";
            Query query = sc.createQuery(hql);
            ds = query.list();
        } catch (Exception e) {
            System.err.println(e);
        } finally {
            sc.close();
        }
        return ds;
    }
    public static  Nhanxet layThongTinNhanXet(int id){
        Nhanxet nhanxet=null;
        Session sc=HibernateUtil.getSessionFactory().openSession();
        try {
            nhanxet =(Nhanxet)sc.get(Nhanxet.class, id);
            Hibernate.initialize(nhanxet.getDeal());
        } catch (HibernateException e) {
            System.err.println(e);
        }finally{
            sc.close();
        }
        return  nhanxet;
    }
    public static void ChapNhan(Nhanxet nx) {
    }
}
